/**
 * DataSetDialog.java : [com.shift.beaver2.metafile.editors] Created on 2009. 1. 20.
 * 
 * Copyright (c) 2000-2008 Shift Information & Communication Co.
 * 5F, Seongsu Venture town, 231-1, Seongsu2-Ga Seongdong-Gu, Seoul, Korea 133-826
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Shift Information & Communication Co. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use 
 * it only in accordance with the terms of the license agreement you 
 * entered into with Shift Information & Communication.
 */
package com.shift.converter.editors;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class DataSetDialog extends Dialog {

	public String name = "";
	public String xpath = "";
	public String url = "";
	
	private Text nameText = null;
	private Text xpathText = null;
	private Combo urlCombo = null;
	
	private String[] items = new String[0];

	private final String[] TYPE_ITEMS = {"XML", "JSON"};
	private final String DEFAULT_CHARSET = "UTF-8";

	public DataSetDialog(Shell parentShell, String[] items) {
		super(parentShell);
		this.items = items;
	}
	
	private void initData() {
		nameText.setText(name);
		xpathText.setText(xpath);
		urlCombo.setItems(items);
		urlCombo.setText(url);
	}
	
	protected Control createDialogArea(Composite parent) {
		Composite container = (Composite) super.createDialogArea(parent);
		container.getShell().setText("Add URL");
		final GridLayout layout = new GridLayout();
		layout.numColumns = 3;
		container.setLayout(layout);
		
		final Label typeLabel = new Label(container, SWT.NONE);
		GridData gd = new GridData(GridData.FILL);
		typeLabel.setText("Name :");
		typeLabel.setLayoutData(gd);
		
		// dataset name
		nameText = new Text(container, SWT.BORDER);
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 2;
		gd.widthHint = 200;
		nameText.setLayoutData(gd);
		
		final Label xpathLabel = new Label(container, SWT.NONE);
		gd = new GridData(GridData.FILL);
		xpathLabel.setText("XPath :");
		xpathLabel.setLayoutData(gd);
		
		// dataset xpath
		xpathText = new Text(container, SWT.BORDER | SWT.READ_ONLY);
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 2;
		gd.widthHint = 300;
		xpathText.setLayoutData(gd);
		
		final Label urlLabel = new Label(container, SWT.NONE);
		gd = new GridData(GridData.FILL);
		urlLabel.setText("Url Name :");
		urlLabel.setLayoutData(gd);
		
		// dataset url Name
		urlCombo = new Combo(container, SWT.NONE);
		gd = new GridData(GridData.FILL);
		gd.horizontalSpan = 2;
		gd.widthHint = 100;
		urlCombo.setLayoutData(gd);
		
		initData();
		addControlEvent();
		return container;
	}
	
	private void addControlEvent() {
		
	}
	
	protected void okPressed() {
		name = nameText.getText();
		//xpath = xpathText.getText();
		url = urlCombo.getText();
		super.okPressed();
	}
}